<template>
  <div>
    <el-container class="page">
      <el-aside width="200px">
        <!-- 侧边栏导航 
        background-color：背景色?????????????????
        text--color:字体颜色
        active-text-color:激活的文本颜色
        unique-opened：是否只保持一个子菜单的展开
        router：是否使用 vue-router 的模式，启用该模式会在激活导航时以 index 作为 path 进行路由跳转
        -->
        <el-menu
          class="el-menu-vertical-demo"
          text-color="#fff"
          active-text-color="#ffd04b"
          unique-opened
          router
        >
          <el-menu-item index="/">
            <i class="el-icon-menu"></i>
            <span slot="title">首页</span>
          </el-menu-item>
          <!-- 动态侧边栏 -->
          <div v-for="item in info.menus" :key="item.id">
            <!-- 有children -->
            <el-submenu :index="item.id+''" v-if="item.children">
            <template slot="title">
              <i :class="item.icon"></i>
              <span>{{item.title}}</span>
            </template>
            <el-menu-item v-for="i in item.children" :key="i.id" :index="i.url">{{i.title}}</el-menu-item>
          </el-submenu>
          <!-- 无children -->
          
           <el-menu-item  :index="item.url" v-else>
             <i class="el-icon-view"></i>
               <span slot="title"> {{item.title}}</span>
           </el-menu-item>
         
          </div>

          <!-- <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>系统设置</span>
            </template>
            <el-menu-item index="/menu">菜单管理</el-menu-item>
            <el-menu-item index="/role">角色管理</el-menu-item>
            <el-menu-item index="/manage">管理员管理</el-menu-item>
          </el-submenu>

          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>商城管理</span>
            </template>
            <el-menu-item index="/cate">商品分类</el-menu-item>
            <el-menu-item index="/specs">商品规格</el-menu-item>
            <el-menu-item index="/goods">商品管理</el-menu-item>
            <el-menu-item index="/vip">会员管理</el-menu-item>
            <el-menu-item index="/banner">轮播图管理</el-menu-item>
            <el-menu-item index="/seckill">秒杀活动</el-menu-item>
          </el-submenu> -->
        </el-menu>
      </el-aside>
      <el-container>
        <el-header>
          <h3>{{info.username}}</h3>
          <el-button @click="logout()">退出登录</el-button>
        </el-header>
        <el-main>
          <!-- 面包屑 -->
          <el-breadcrumb separator="/" v-if="$route.meta.title" class="mianbao">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>
              <a href="/">{{$route.meta.title}}</a>
            </el-breadcrumb-item>
          </el-breadcrumb>
          <!-- 二级路由出口 -->
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
export default {
  components: {},
  computed: {
    ...mapGetters({
      info:"info"
    }),
  },
  methods: {
    ...mapActions({
      changeInfo:"changeInfo"
    }),
    logout(){
      this.changeInfo({});
      this.$router.replace("/login")
    }
  },
  mounted() {},
  props: [],
  data() {
    return {};
  },
};
</script>
<style lang="less">
@import "../../less/index.less";
.page {
  height: 100vh;
}
.el-aside {
  background: @info;
}
.el-header {
  background: @header-color;
  height: 80px;
}
.mianbao {
  margin-bottom: @margin;
}
.el-menu-vertical-demo,
.el-menu {
  background: @info;
}
.el-menu-item:focus,
.el-menu-item:hover,
/deep/.el-submenu__title:hover {
  background: @header-color;
}
</style>